/*
 * @Description:
 * @Author: SongWenJie
 * @LastEditors: SongWenJie
 * @Date: 2024-07-19 16:40:45
 * @LastEditTime: 2024-07-20 00:41:24
 */
// src/store/layoutSlice.js

import { createSlice } from "@reduxjs/toolkit";
import { getTheme } from "../styles/theme";

const initialState = {
  collapsed: false,
  theme: "light",
  currentTheme: getTheme("light"),
};

const layoutSlice = createSlice({
  name: "layout",
  initialState,
  reducers: {
    toggleCollapsed: (state) => {
      state.collapsed = !state.collapsed;
    },
    toggleTheme: (state) => {
      state.theme = state.theme === "light" ? "dark" : "light";
      state.currentTheme = getTheme(state.theme);
    },
  },
});

export const { toggleCollapsed, toggleTheme } = layoutSlice.actions;
export default layoutSlice.reducer;

